package com.rewind.test.conf;

import com.rewind.test.entity.Person;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.*;

// 该注解标注了该类为配置类，即相当于Spring的配置文件的作用
@Configuration(proxyBeanMethods = true)
//@Import({Person.class})
public class MyConf {

    // 该注解用于加载bean，相当于Spring的配置文件的bean标签
    // 默认bean的名称为方法名，也可通过value属性指定bean的名称
    @Bean
    @Scope("prototype")     //注解标注bean为多例
    public Person person(){
        return new Person();
    }

    @Bean(value = "person2")
    @ConditionalOnBeanAndProperty
    //@Conditional(BeanAndProperty.class)
    public Person getPerson(){
        return new Person();
    }


}
